<?php
    
    session_start();
    if(!isset($_SESSION['usuario'])){
            header('location:../html/login.html');
         }
         
         $nombres = $_REQUEST["nomb"];
?>

<!DOCTYPE html>
<html>
    <head>
        <title>Inicio</title>
        <link href="../css/menu/main.css" rel="stylesheet" type="text/css">
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <link href="../css/menu/css/layout.css" rel="stylesheet" type="text/css" />
        <link href="../css/menu/css/menu.css" rel="stylesheet" type="text/css" />
        <script src="jquery-1.9.1.min.js"></script>
        <!--<link rel="stylesheet" type="text/css" href="../css/prueba.css" />-->
        <!--<link rel="stylesheet" type="text/css" href="../cssMenu/css.css" />
        <link rel="stylesheet" type="text/css" href="../cssMenu/font-awesome.css" />
        <link rel="stylesheet" type="text/css" href="../cssMenu/styles.css" />
        <script src="jquery-1.8.2.min.js"></script>-->
        <script src="jquery-1.9.1.min.js"></script>
        
        <script>
            function bien(){
                /*funcion para invocar el funcionamiento de el calendario*/
                //var val = document.getElementById('hdnu').value;
                //alert(""+val);
                if($("#hdnu").val() !== ""){
                    document.getElementById("bien").innerHTML = "<table border=''>\
                                                                    <tr>\
                                                                        <td>\
                                                                            Bienvenido "+ $("#hdnu").val() +"\
                                                                        </td>\
                                                                    </tr>\
                                                                 </table>";
                }else{
                    document.getElementById("bien").innerHTML = "";
                }
            }
        </script>
        <script type="text/javascript">
                idleTime = 0;
                $(document).ready(function () {
                    //Increment the idle time counter every minute.
                    var idleInterval = setInterval("timerIncrement()", 300000); // 5 minutes

                    //Zero the idle timer on mouse movement.
                    $(this).mousemove(function (e) {
                        idleTime = 0;
                    });
                    $(this).keypress(function (e) {
                        idleTime = 0;
                    });
                })
                function timerIncrement() {
                    idleTime = idleTime + 1;
                    if (idleTime > 4) { // 20 minutes
                        window.location.reload();
                    }
                }
            </script>
        
        <?php
            echo '<center>
                  <div id="conte">
                       <table id="tablit" align="center">
                           <tr>
                               <td colspan=2>
                                    <img src="../imagen/BANNERSES.png" width="1250" height="125" alt="BANNERSES"/>
                               </td>
                           </tr>
                           <tr>
                           </tr>
                            <tr>
                                <td>';
        ?>
    </head>
    <body>
    <div id="wrapper">
                                        <nav>
                                            <ul id="nav">
                                                 <?php
                    include '../../controlador/php/conexion/Conexion.php';
                    $con = new Conexion();
                    
                    $n = $_SESSION['tama'];//tamaño de la lista(Modulos y submodulos)
                    $i = 0;
                    $temp = "";
                    $oidmod = "";
                    $cont = 0;
                   // $oidmod2 = 0;
                    /*sacamos variables de sesion del menu*/
                    while($i < $n){
                        $modulo = $_SESSION['modulo'.$i];
                        $submod = $_SESSION['submod'.$i];
                        $dire = $_SESSION['dir'.$i];
                        //$oidmod2 = $_SESSION['mod2'.$cont];
                        //condicionamos para que no se repita el nombre del modulo
                        if($temp != $modulo){
                            $oidmod = $_SESSION['mod1'.$i];
                            /*se condiciona para cuando el contador inicielice en 0 y cerrar el modulo*/
                             if($cont != 0){
                                print("</ul></li>");
                            }
                            echo"<li>
                                        <a href='#'>".$modulo."</a><ul>";
                        }
                                echo"
                                        <li>
                                            <a href='".$dire."'>".$submod."</a>
                                        </li>";
                        $temp = $modulo;
                        $i++;
                        $cont++;
                    }
                   
                
                 /* include '../../controlador/php/conexion/Conexion.php';
                     $con = new Conexion();
                     $sql = "select mod_descripcion,modulo.mod_oid
                             from modulo inner join submodulo on modulo.mod_oid=submodulo.mod_oid
                             inner join config on submodulo.sub_oid=config.sub_oid
                             inner join roll on config.rol_oid=roll.rol_oid
                             where roll.rol_oid = '".$_SESSION['roll']."'
                             group by mod_descripcion,modulo.mod_oid
                             order by mod_descripcion asc";
                     $respu = $con->query($sql);
                     while ($res = mssql_fetch_array($respu)){

                            echo"<li><a href='#'>".$res['mod_descripcion']."</a><ul>";
                     /*$sq = "select modulo.mod_oid
                            from modulo inner join submodulo on modulo.mod_oid=submodulo.mod_oid
                            inner join config on submodulo.sub_oid=config.sub_oid
                            inner join roll on config.rol_oid=roll.rol_oid
                            where roll.rol_oid = '".$_SESSION['roll']."'
                            group by modulo.mod_oid ";
                     $respu = $con->query($sq);
                     while ($ress = mssql_fetch_array($respu)){

                     }*/
                    /* $sql2 = "select sub_descripcion,sub_dir
                              from modulo inner join submodulo on modulo.mod_oid=submodulo.mod_oid
                              inner join config on submodulo.sub_oid=config.sub_oid
                              inner join roll on config.rol_oid=roll.rol_oid
                              where roll.rol_oid =".$_SESSION['roll']." and modulo.mod_oid= ".$res['mod_oid']." 
                              group by sub_descripcion,sub_dir
                              order by sub_descripcion asc";
                      $respu2 = $con->query($sql2);

                      while ($res2 = mssql_fetch_array($respu2)){

                            echo"<li><a href='".$res2['sub_dir']."'>".$res2['sub_descripcion']."</a></li>";

                      }

                      echo"</ul></li>";

                      }


                      $con->cerrarConexion();*/
                      ?>

            </ul>          
        </nav>
                           <?php
                                         echo '
                           
                              <td align=right id="sesion"><strong>Sesion:</strong> '.$_SESSION['nombre'].'
                              <a href="../../controlador/php/sql/cerrarSesion.php">
                                      <img src="../imagen/cesesion.png" title="cerrar sesion" width="20" height="20" alt="csesion" align="absbottom"/>
                                  </a>
                              </td>';
                           ?>
                      </tr>
                      <tr>
                          <td>
                              <input  type="hidden" id="hdnu" value="<?php echo$nombres ?>" />
                          </td>
                      </tr>
              </table>
              </br></br>
              <table>
                  <tr>
                          <td align="center" colspan="2">
                              <div id="bien">
                                  
                              </div>
                          </td>
                      </tr>
              </table>
              </div>
    </body>
</html>
              <div>
     </center>
     
